// pages/admin_infor/admin_infor.js
Page({
  data:{
      inputdisplay:'display:none;',
      display:'',
      bianjitext:'编辑',
    sex:['男','女'],
    index:0,
    userId:'1',
    nickname:'',
    user:{
        useId:'1',
        userName:'2',
        userNickname:'3',
        telNum:'4',
    }
  },
  bianji(){
    var that = this;
    
    if(that.data.user.userNickname == that.data.nickname){
        that.setData({
        display:'display:none;',
        inputdisplay:'',
        bianjitext:'确定'
        })
        wx.request({
            url: 'http://localhost:8080/user/alterUser?userId='+that.data.user.useId+'&nickname='+that.data.nickname+'&password='+that.data.user.password,
            method:'GET',
            header:{
                'content-type':'application/json'
            },
            success:function(res){
                that.setData({
                    user:res.data,
                    display:'',
                    inputdisplay:'display:none',
                })

                that.queryUserInfo();

                // console.log(res.data);
                // console.log(that.data.user.userNickname)
            }
        })
    
    }
    
  },
  binPickerChange:function(e){
    this.setData({
      index:e.detail.value
    })
  },
  queryUserInfo(){
    var that = this; 
    var app = getApp();
    that.data.userId = app.data.useId;
    wx.request({
        url: 'http://localhost:8080/user/search?userId='+that.data.userId,
        method:'GET',
        header:{
            'content-type':'application/json'
        },
        success:function(res){
            console.log(res.data);
            that.setData({
                user:res.data.data
            })
        }
    })
  },
  onShow(){
    this.queryUserInfo();
  }
})